#include "SdkMediaInit.h"
#include "InSdkCallbackFunction.h"

#define DEF_TAG             "MediaInit"

Com_s32 Ext_Sdk_Media_Init(void)
{
    Com_s32 ret = DEF_COM_FAILED;

#if CMAKE_ANYKA_EV300L
    sdk_run_config config;
    memset(&config,0,sizeof(config));             //init the struct
    config.mem_trace_flag = SDK_RUN_NORMAL;
    config.isp_tool_server_flag = 0;                //isp tool sever

    ak_sdk_init(&config);
#endif

    ret = Ext_SdkVideo_Init();
    if (ret != DEF_COM_SUCCESS)
    {
        PRT_ERR(DEF_TAG,"video init failed !\n");
        return DEF_COM_FAILED;
    }

    ret = Ext_SdkMic_Init();
    if(ret != DEF_COM_SUCCESS)
    {
        PRT_ERR(DEF_TAG,"mic init failed !\n");
        return DEF_COM_FAILED;
    }

    ret = Ext_SdkSpk_Init();
    if(ret != DEF_COM_SUCCESS)
    {
        PRT_ERR(DEF_TAG,"spk init failed !\n");
        return DEF_COM_FAILED;
    }

    return DEF_COM_SUCCESS;
}

Com_s32 Ext_Sdk_Media_Exit(void)
{
    Com_s32 ret = DEF_COM_FAILED;

    ret = Ext_SdkSpk_Exit();
    if(ret != DEF_COM_SUCCESS)
    {
        printf("spk exit failed !\n");
        return DEF_COM_FAILED;
    }

    ret = Ext_SdkMic_Exit();
    if(ret != DEF_COM_SUCCESS)
    {
        printf("mic exit failed !\n");
        return DEF_COM_FAILED;
    }

    ret = Ext_SdkVideo_Exit();
    if(ret != DEF_COM_SUCCESS)
    {
        printf("video exit failed !\n");
        return DEF_COM_FAILED;
    }

#if CMAKE_ANYKA_EV300L
    ak_sdk_exit();
#endif

    PRT_INFO(DEF_TAG,"media exit\n");
    return DEF_COM_SUCCESS;
}
